const os = require('os');
const exec = require('child_process').exec;

server.listen(8080, () => {
    console.log('Server started at http://localhost:8000');
    const openCommands = {
        darwin: 'open',
        win32: 'start',
        default: 'xdg-open'
    };
    const platform = os.platform();
    const command = `${openCommands[platform] || openCommands.default} http://localhost:8080`;

    exec(command, (error) => {
        if (error) {
            console.error(`Error opening browser: ${error}`);
        } else {
            console.log('Successfully opened browser.');
        }
    });
}).on('error', (e) => {
    console.error(`Failed to start server: ${e.message}`);
});